package edu.xmist.demo15.core;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * 单例：
 * <p>
 * 初始化方式： 1. 饿汉式加载  2. 懒汉式加载
 */
public class DbGlobalStatistics implements Statistics {

    private static final DbGlobalStatistics INSTANCE = new DbGlobalStatistics();

    public static final DbGlobalStatistics getInstance() {
        //1. xxxx
        return INSTANCE;
    }

    private AtomicInteger count = new AtomicInteger(0);

    private DbGlobalStatistics() {
        //get count from db.
    }

    @Override
    public int incr() {
        int result = count.incrementAndGet();
        //save result to db
        return result;
    }
}
